<?php
/**
 * Smarty plugin
 * *feito pelo Werneck
 * -------------------------------------------------------------
 * File:     function.js.php
 * Type:     function
 * Name:     js
 * Purpose:  script helper
 * -------------------------------------------------------------
 */
function smarty_function_js($params, &$view)
{
	if (!empty($params['file'])) {
	
		$filename = $params['file'];
				
		if (!file_exists(APP_ROOT . "js" . DS . $filename)) 
		{
			trigger_error("assign: invalid 'file' parameter: uneable to locate $path");
			return;
		}
		
		$path = WEB_ROOT . "js/" . $filename;

	} 
	else if (!empty($params['url'])) {
		$path = $params['url'];
	}
	else {
		trigger_error("assign: missing 'file' or 'url' parameter");
		return;
	}
	
	return '<script type="text/javascript" src="'.$path.'"></script>';
}
?>